@extends("public.main")
@section("content")
    <div style="margin-left:200px;">
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 订单管理 <span
                    class="c-gray en">&gt;</span> 订单列表
        </nav>
        <div class="page-container">
            <form method="post" action="" id="form1">
                <div class="text-c"> 下单时间：
                    <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})"
                           id="datemin"
                           class="input-text Wdate" name="datemin" style="width:120px;">
                    -
                    <input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})"
                           id="datemax" class="input-text Wdate" name="datemax" style="width:120px;">

                    角色: <span class="select-box inline">
				  <select name="role" class="select">
                            <option value="">---请选择角色---</option>
                            <option value="0">学生宿舍</option>
                            <option value="1">教学楼</option>
                    </select>
				</span>
                    </span>
                    功能选择: <span class="select-box inline">
				  <select name="status" class="select">
                            <option value="0">搜索</option>
                            <option value="1">下载</option>
                    </select>
				</span>
                    <button class="btn btn-primary radius" name="">执行</button>
                </div>
            </form>
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                        <th width="40">ID</th>
                        <th width="50">用户名</th>
                        <th width="30">角色</th>
                        <th width="50">学校</th>
                        <th width="50">学院</th>
                        <th width="50">宿舍</th>
                        <th width="50">学号</th>
                        <th width="60">联系电话</th>
                        <th width="60">预约时间</th>
                        <th width="50">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    @if(!empty($data['data']))
                        @foreach($data['data'] as $k => $v)
                            <tr class="text-c va-m">
                                <td>{{ $v['id'] }}</td>
                                <td>{{ $v['name'] }}</td>
                                <td>@if($v['role']==0)学生 @else 教师@endif</td>
                                <td>{{ $v['school'] }}</td>
                                <td>{{ $v['college'] }}</td>
                                <td>{{ $v['dormitory'] }}</td>
                                <td>{{ $v['student_num'] }}</td>
                                <td>{{ $v['mobile'] }}</td>
                                <td>{{ $v['appointment_time'] }}</td>
                                <td class="td-manage"><a style="text-decoration:none" class="ml-5"
                                                         onclick="delorder(this,{{$v['id'] }})" title="删除"><i
                                                class="Hui-iconfont">&#xe6e2;</i></a></td>
                            </tr>
                        @endforeach
                    @else
                        <tr class="text-c va-m">暂无数据</tr>
                    @endif
                    </tbody>
                </table>
                <div id="pagelist" style="float:right;margin-top:10px">
                    @if(!empty($data['data']))
                    {!! $data['data']->appends(['type' => $data['type']])->render() !!}
                    @endif
                </div>
            </div>
        </div>
    </div>
@endsection

<script>
    /*产品-删除*/
    function delorder(obj, id) {
        var token = "{{csrf_token()}}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: '/admin/appointment/del',
                data: {id: id, _token: token},
                dataType: 'json',
                success: function (data) {
                    if (data.status == 200) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 1, time: 1000});
                    }
                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    }

</script>